<?php
require_once('../carbox.php');
if(!carbox_check_session( ))
	header('Location: http://'.$_SERVER['HTTP_HOST'].'/carbox/login.php');
?>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
	var result = new Array;

	function drawChart( ) {
		var data = google.visualization.arrayToDataTable(result);
		var chart = new google.visualization.ColumnChart(document.getElementById('chart'));
			chart.draw(data);
	}

	$('#chart').css('height', $(window).height( ) - 100);

	$('#select-chart').change(function( ) {
		$.ajax({
			url: 'php/account/charts.php',
			type: 'post',
			data: { chart: $('#select-chart').val( ) },
			success: function(rs) {
				result = rs;
				google.load('visualization', '1.0', {'packages':['corechart'], "callback": drawChart});
			},
			dataType: 'json'
		});
	});

	$('#select-chart').trigger('change');
</script>
<div class="container-fluid">
	<div class="row-fluid">
		<select class="span12" id="select-chart">
			<option value="1">Páginas carregadas por mês</option>
			<option value="2">Documentos carregados por mês</option>
			<option value="3">Processos carregados por mês</option>
		</select>
	</div>
	<div class="row-fluid">
		<div class="span12" id="chart"></div>
	</div>
</div>
